package com.ppt.javappt.pojo;

import com.ppt.javappt.entity.Slide;
import javafx.scene.Node;

import java.util.ArrayList;
import java.util.List;

public class SlideFactory {
    public static SlideData createSlideData(Slide slide){
        SlideData slideData = new SlideData();
        List<NodeData> dataList = new ArrayList<>();
        for(Node node : slide.getChildren()){
            NodeData data = NodeFactory.createDataFromNode(node);
            dataList.add(data);
        }
        slideData.setNodeDataList(dataList);
        return slideData;
    }
    public static Slide createSlide(SlideData slideData){
        List<NodeData> dataList = slideData.getNodeDataList();
        Slide slide = new Slide();
        for(NodeData data:dataList){
            Node node = NodeFactory.createNode(data);
            slide.getChildren().add(node);

        }
        return slide;
    }
}
